﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using AppStart.Models;
using NewLife.Xml;

namespace AppStart.Common
{
    /// <summary>配置</summary>
    [XmlConfigFile(@"Config\Star.config", 15_000)]
    public class Setting : XmlConfig<Setting>
    {
        #region 属性
        /// <summary>调试开关。默认true</summary>
        [Description("调试开关。默认true")]
        public Boolean Debug { get; set; } = true;

        /// <summary>应用服务集合</summary>
        [Description("应用服务集合")]
        public ServiceInfo[] Services { get; set; }
        #endregion

        #region 构造
        ///// <summary>实例化</summary>
        //public Setting()
        //{
        //}
        #endregion

        #region 方法
        protected override void OnLoaded()
        {
            if (Services == null || Services.Length == 0)
            {
                var si = new ServiceInfo
                {
                    Name = "test",
                    FileName = "cmd",
                    Arguments = "ping baidu.com",

                    AutoStart = false,
                    AutoRestart = true,
                    RestartExistCodes = "0,1,3",
                };

                Services = new[] { si };
            }

            base.OnLoaded();
        }
        #endregion
    }
}
